<?php 
/**
 * GioCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@ninhgio.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2010-2011 GioCMS (http://cms.ninhgio.com)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @author		NinhGio - ninhgio@gmail.com
 * @since		1.0
 */
?>
<form method="post" action="<?php echo $this->url('comment_comment_send'); ?>" id="gCommentSend">
	<div class="g_comment mb5">
		<div class="g_comment_head">
		    <a href="javascript: void(0);" id="g_comment_button_open" class="g_comment_button_hide"><span><?php echo $this->TRANSLATOR->widget('comment_title'); ?></span></a>
		</div>
		<div class="g_comment_content" style="display: none;">
			<div class="g_comment_content_padding">
				<div class="rows clearfix">
					<div class="rows_left"><input class="g_comment_input" title="<?php echo $this->STRING->escape($this->TRANSLATOR->widget('fullname')); ?>" type="text" style="color: #A3C1D4;" name="comment[full_name]" class="g_comment_text name" value="<?php echo $this->STRING->escape($this->TRANSLATOR->widget('fullname')); ?>"></div>
					<div class="rows_right"><input class="g_comment_input" title="<?php echo $this->STRING->escape($this->TRANSLATOR->widget('email')); ?>" type="text" style="color: #A3C1D4;" name="comment[email]" class="g_comment_text email" value="<?php echo $this->STRING->escape($this->TRANSLATOR->widget('email')); ?>"></div>
				</div>
				<div class="rows clearfix">
					<div class="rows_left"><input class="g_comment_input" title="<?php echo $this->STRING->escape($this->TRANSLATOR->widget('title')); ?>" type="text" style="color: #A3C1D4;" name="comment[title]" class="g_comment_text subject" value="<?php echo $this->STRING->escape($this->TRANSLATOR->widget('title')); ?>"></div>
					<div class="rows_right"><input class="g_comment_input" title="<?php echo $this->STRING->escape($this->TRANSLATOR->widget('phone')); ?>" type="text" style="color: #A3C1D4;" name="comment[phone]" class="g_comment_text phone" value="<?php echo $this->STRING->escape($this->TRANSLATOR->widget('phone')); ?>"></div>
				</div>
				<div class="box_rows clearfix"><textarea class="g_comment_input" title="<?php echo $this->STRING->escape($this->TRANSLATOR->widget('content')); ?>" style="color: #A3C1D4;" name="comment[content]" class="g_comment_text message"><?php echo $this->STRING->escape($this->TRANSLATOR->widget('content')); ?></textarea></div>
				<div class="box_rows clearfix">
					<a href="javascript: void(0);" class="ar-freedback-submit"><span><?php echo $this->STRING->escape($this->TRANSLATOR->widget('send')); ?></span></a>
					<a href="javascript: void(0);" class="ar-freedback-reset"><span><?php echo $this->STRING->escape($this->TRANSLATOR->widget('reset')); ?></span></a>
					<a href="javascript: void(0);" class="ar-freedback-close"><span><?php echo $this->STRING->escape($this->TRANSLATOR->widget('close')); ?></span></a>
				</div>
				
				<div class="g_comment_note"><?php echo $this->STRING->escape($this->TRANSLATOR->widget('guide')); ?></div>
				
				<input type="hidden" value="<?php echo Gio_Core_Application::getRoute('name'); ?>" name="comment[route]" />
				<input type="hidden" value="<?php echo $this->paramString; ?>" name="comment[params]" />
			</div>
		</div>
	</div>
</form>

<?php if (isset($this->comments) && $this->comments) : ?>
<div class="g_comment" id="g_comment_box_container"> 
	<div class="g_comment_box">
		<div class="g_comment_box_header">Ý kiến bạn đọc</div>
		<div class="g_comment_box_content">
			<div id="g_comment_box_content_display">
				<div class="customScrollBox">
					<div class="container">
						<div id="feedback-list" class="content list">
							<?php foreach ($this->comments as $index => $comment) : ?>
							<div class="g_comment_item">
								<div class="g_comment_item_h">.</div>
								<div class="g_comment_item_c">
									<div class="padding_5">
										<p class="title"><b><?php echo sprintf($this->TRANSLATOR->widget('comment_info'), $comment['full_name'], date($this->CONFIG->timezone->datetime, strtotime($comment['created_date']))); ?></b></p>
										<p class="description"><b><i><?php echo $comment['title']; ?>:</i></b> <?php echo $comment['content']; ?></p>
									</div>
								</div>
								<div class="g_comment_item_f">.</div>
							</div>
							<?php endforeach; ?>
						</div>
					</div>
					<div class="dragger_container" style="display: block;">
						<div class="dragger ui-draggable" style="display: block; top: 0px;"></div>
					</div>
				</div>
			</div>
			<div class="pagy cm-page" id="paging" style="padding: 0 5px;"><?php echo $this->pager->links; ?>&nbsp;<label class="recordcount"><?php echo sprintf($this->TRANSLATOR->widget('comment_total'), $this->numComments); ?></label></div>
			<div class="g_comment_box_footer">.</div>
		</div>
	</div>
</div>
<?php endif; ?>
<script type="text/javascript">
$(document).ready(function() {
	<?php if (($string = $this->MESSENGER->printMessages(false)) != null) : ?>
	alert('<?php echo $string; ?>');
	<?php endif; ?>
	$('#g_comment_button_open').click(function() {
		var self = this;
		if ($('#g_comment_button_open').hasClass('g_comment_button_hide')) {
			$('#g_comment_button_open').removeClass('g_comment_button_hide')
			   						   .addClass('g_comment_button_show');
		} else {
			$('#g_comment_button_open').removeClass('g_comment_button_show')
			   						   .addClass('g_comment_button_hide');
		}
		var parents = $(self).parents('.g_comment');
		$(parents).find('.g_comment_content:first').toggle();
		$(parents).find('.ar-freedback-close:first').unbind('click').bind('click', function() {
			$(parents).find('.g_comment_content:first').toggle();
			$('#g_comment_button_open').removeClass('g_comment_button_show')
									   .addClass('g_comment_button_hide');
		});
	});

	$('.ar-freedback-submit').click(function() {
		$('#gCommentSend').submit();
	});

	$('.g_comment_input').focus(function() {
		var self = this;
		var title = $(self).attr('title');
		var value = $(self).val();
		if (value == title) {
			$(self).css('color', '#333');
			$(self).val('');
		}
	}).blur(function() {
		var self = this;
		var title = $(self).attr('title');
		var value = $(self).val();
		if (value == '') {
			$(self).css('color', '#A3C1D4');
			$(self).val(title);
		}
	});
});

'Comment.Widgets.Comment'.namespace();
Comment.Widgets.Comment.loadComments = function(page) {
	var params = 'pageIndex=' + page + '|limit=<?php echo $this->limit; ?>|paramString=<?php echo $this->STRING->escape($this->paramString); ?>';
	Gio.Core.Widget.Loader.baseUrl = '<?php echo $this->url('core_widget_ajax'); ?>';
	Gio.Core.Widget.Loader.cacheEnable = '<?php if ($this->cacheEnable) : ?>true<?php else : ?>false<?php endif; ?>';
	Gio.Core.Widget.Loader.cacheTimeout = '<?php if ($this->cacheTimeout) : ?><?php echo $this->cacheTimeout; ?><?php else : ?>false<?php endif; ?>';
	Gio.Core.Widget.Loader.queueAction('comment', 'comment', 'load', params, $('#g_comment_box_container'), '');
};
</script>